﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// UserAction 的摘要说明
/// </summary>
public class UserActions
{
    /// <summary>
    /// 用户登录验证
    /// </summary>
    /// <param name="account">帐号</param>
    /// <param name="password">密码</param>
    /// <returns>登录人ID</returns>
    public DataTable Login(string account, string password)
    {
        string sql = "select ID from [temple_Users] where [Account] = @acc and [Password] = @pass and [IsDel] = 0";
        SqlParameter[] param = {
            new SqlParameter("@acc",account),
            new SqlParameter("@pass",password)
        };
        return DBHelper.GetDataTable(sql, param);
    }

    public bool CheckUser(int loginID, string password)
    {
        string sql = "select count(ID) from [temple_Users] where [ID ] = @id and [Password] = @pass and [IsDel] = 0";
        SqlParameter[] param = {
            new SqlParameter("@id",loginID),
            new SqlParameter("@pass",password)
        };
        return int.Parse(DBHelper.GetDataTable(sql, param).Rows[0][0].ToString()) > 0;
    }
}